package com.example.exp_3_javaweb;

import javax.servlet.ServletContext;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;

@WebServlet("/receiveservlet")

public class ReceiveServlet extends HttpServlet {
    @Override
    public void doGet(HttpServletRequest request,HttpServletResponse response) throws UnsupportedEncodingException {
        request.setCharacterEncoding("utf-8");

        Student stu1 = (Student) request.getAttribute("student");

        HttpSession session = request.getSession();
        Student stu2 = (Student) session.getAttribute("student");

        ServletContext application = this.getServletContext();
        Student stu3 = (Student) application.getAttribute("student");

        System.out.println(stu1.getName());
        System.out.println(stu2.getGender());
        System.out.println(Arrays.toString(stu3.getHobby()));
    }
}
